package testing.src.vineet.java.code.stack;

import testing.src.vineet.java.code.linklist.MyLinkList;
import testing.src.vineet.java.code.node.Node;



public class MyStack<T> implements Stack<T>
{
	private Top<T> top;
	private MyLinkList<T> ml ;
	
	public MyStack()
	{
		top = new Top<T>();
		ml = new MyLinkList<T>();
	}
	
	@Override
	public void push(T value)
	{
		Node<T> tmp = new Node<T>(value);
		top.setTop(tmp);
		top.setCount(top.getCount()+1);
		this.ml.add(tmp);
	}
	
	@Override
	public Node<T> pop()
	{
		Node<T> tmp = null;
		if(top.getCount() == 0)
		{
			return null;
		}
		tmp = this.ml.delete(this.ml.getLength());
		return tmp;
	}
	
	public void print()
	{
		this.ml.print();
	}
}
